Unit BFormMainUnit;

{$mode objfpc}{$H+}

Interface

Uses
  Classes, SysUtils, BSessionUnit, BDojoWebUnit;

Type

{ BFormMainClass }

 BFormMainClass = Class(BWebFormClass)
  Private
    bBottomLayout: BWebLayoutGridClass;
    bLayoutTable: BWebLayoutTableClass;
    bEditLogin: BWebEditClass;
    bEditPassword: BWebEditClass;

    bPanelInfo: BWebPanelClass;

    bButtonOk: BWebButtonClass;
    bButtonCancel: BWebButtonClass;

    bSpacer: BWebPanelClass;


    Procedure BuildLayout;
    Procedure ButtonClick;
  Public
    Constructor Build(Const aSession: BSessionClass);
End;

Implementation

{ BFormMainClass }

Procedure BFormMainClass.BuildLayout;
Begin
  bLayoutTable := BWebLayoutTableClass.Build(Self, rgCenter);
  bLayoutTable.Style := 'width: 97%';

  bEditLogin := BWebEditClass.Build(bLayoutTable, 'Login: ');
  bEditLogin.Style := 'width: 99%';
  bEditPassword := BWebEditClass.Build(bLayoutTable, 'Password: ');
  bEditPassword.HTMLType := 'password';
  bEditPassword.Style := 'width: 99%';
  bPanelInfo := BWebPanelClass.Build(bLayoutTable);
  bPanelInfo.ContentString := 'Correct Login/Password pair is Demo/demo';

  bBottomLayout := BWebLayoutGridClass.Build(Self, rgBottom);
  bBottomLayout.Dir := 'rtl';
  bBottomLayout.Startup;
  bBottomLayout.DisableDnD;

  bButtonCancel := BWebButtonClass.Build(bBottomLayout, 'Cancel',
    '%s.close()', [JSName]);
  bButtonOk := BWebButtonClass.Build(bBottomLayout, 'Ok', @ButtonClick,
    [bEditLogin.GetAttr('Login', 'value'),
    bEditPassword.GetAttr('Password', 'value')]);
End;

Procedure BFormMainClass.ButtonClick;
Begin
  If (ByString('Login') = 'Demo') And (ByString('Password') = 'demo') Then
    SetAttr('title', 'Successful')
  Else
    SetAttr('title', 'Unsuccessful');
End;

Constructor BFormMainClass.Build(Const aSession: BSessionClass);
Begin
  Inherited Build(aSession, 400, 150);
  Layout := lyBorder;
  Resizable := TRUE;
  Title := 'Form';
  BuildLayout;
  Startup;
End;

End.

